package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.AddressBook;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;


@Mapper
public interface AddressBookMapper {

    /**
     * 查询地址
     * @return
     */
    List<AddressBook> list(AddressBook addressBook);

    /**
     * 新增地址
     * @param addressBook
     */
    @Insert("insert into address_book (user_id, consignee, sex, phone, province_code, province_name, city_code, city_name, district_code, district_name, detail, label, is_default)values" +
            " (#{userId},#{consignee},#{sex},#{phone},#{provinceCode},#{provinceName},#{cityCode},#{cityName},#{districtCode},#{districtName},#{detail},#{label},#{isDefault})")
    void add(AddressBook addressBook);

    /**
     * 数据回显
     * @param id
     * @return
     */
    @Select("select * from  address_book where  id=#{id}")
    AddressBook findByid(Long id);

    /**
     * 修改信息
     * @param addressBook
     */
    void updateMessage(AddressBook addressBook);

    /**
     * 设置所有 地址默认 地址 为0
     * @param addressBook
     */
    @Update("update address_book set is_default = #{isDefault} where user_id = #{userId}")
    void setAlldefault(AddressBook addressBook);

    /**
     * 删除地址
     * @param id
     */
    @Delete("delete  from address_book where id=#{id}")
    void deletes(Long id);
}
